home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / Clean 1.2.4 / IO Examples / Scrabble / English / language.icl < prev    next >
Encoding:
Modula Implementation  |  1997-05-14  |  4.2 KB  |  149 lines  |  [TEXT/3PRM]

  1. implementation module language
  2.  
  3.  
  4. import    StdBool, StdList, StdArray, _SystemArray, StdEnum
  5. import    deltaTimer, deltaSystem
  6. import    board
  7.  
  8.  
  9. /*    This module contains macro's to make the scrabble application language customisable.
  10. */
  11.  
  12. //    The filename of the lexicon:
  13.  
  14. lexiconfilename    :==    toString DirSeparator+++"English"+++toString DirSeparator+++"English_lexicon"
  15.  
  16. //    The filename of the help file:
  17.  
  18. helpfilename    :==    toString DirSeparator+++"English"+++toString DirSeparator+++"ScrabbleHelp"
  19.  
  20.  
  21. //    The set of letters used in the scrabble game.
  22.  
  23. letterbox :: [Char]
  24. letterbox 
  25.     =:    repeatn 7  'a' ++ repeatn 2  'b' ++ repeatn 1 'c' ++ repeatn 4 'd' ++
  26.         repeatn 10 'e' ++ repeatn 2  'f' ++ repeatn 3 'g' ++ repeatn 3 'h' ++
  27.         repeatn 5  'i' ++ repeatn 1  'j' ++ repeatn 1 'k' ++ repeatn 4 'l' ++
  28.         repeatn 2  'm' ++ repeatn 4  'n' ++ repeatn 7 'o' ++ repeatn 2 'p' ++
  29.         repeatn 1  'q' ++ repeatn 4  'r' ++ repeatn 5 's' ++ repeatn 5 't' ++
  30.         repeatn 3  'u' ++ repeatn 1  'v' ++ repeatn 2 'w' ++ repeatn 1 'x' ++
  31.         repeatn 2  'y' ++ repeatn 1  'z'
  32.  
  33. lettervalue :: !Char -> Int
  34. lettervalue l
  35. |    isMember l ['a','e','i','l','n','o','r','s','t','u']    = 1
  36. |    l=='d' || l=='g'                                        = 2
  37. |    l=='b' || l=='m' || l=='p' || l=='w'                    = 3
  38. |    l=='c' || l=='f' || l=='h' || l=='y'                    = 4
  39. |    l=='v'                                                    = 5
  40. |    l=='j' || l=='k'                                        = 7
  41. |    l=='x'                                                    = 8
  42. |    l=='q' || l=='z'                                        = 10
  43. |    otherwise                                                = 0        // for the blank letters
  44.  
  45.  
  46. //    String conversion functions:
  47.  
  48. instance toString Player
  49. where
  50.     toString :: !Player -> {#Char}
  51.     toString Player1             = "Player 1"
  52.     toString Player2             = "Player 2"
  53. instance toString Playerkind
  54. where
  55.     toString :: !Playerkind -> {#Char}
  56.     toString Computer            = "Computer"
  57.     toString Person                = "Person"
  58. instance toString Direction
  59. where
  60.     toString :: !Direction -> {#Char}
  61.     toString Hor                = "Across"
  62.     toString Ver                = "Down"
  63. instance toString Strength
  64. where
  65.     toString :: !Strength -> {#Char}
  66.     toString Maximum            = "Maximum"
  67.     toString First                = "First"
  68.     toString MediumStrength        = "Medium"
  69.     toString EasyStrength        = "Easy"
  70.     toString VeryEasyStrength    = "Very Easy"
  71. instance toString (a,b) | toString a & toString b
  72. where
  73.     toString :: !(a,b) -> {#Char} | toString a & toString b
  74.     toString (a,b) = "("+++toString a+++","+++toString b+++")"
  75.  
  76.  
  77. //    Text used to communicate with the user in the display control.
  78.  
  79. exchanges_letters
  80.     :==    " exchanges letters."
  81. placement_error word pos
  82.     :==    [    " by placing the word '"+++word+++"'"
  83.         ,    " at "+++toString pos
  84.         ,    " it will not adjoin any present word."
  85.         ]
  86. anonymous_placement_error
  87.     :==    [    "word can not be place at this position." ]
  88. missing_letters_error cs
  89.     :==    [    "you can not form this word because you do not have the letter(s): "
  90.         ,    "   "+++{c\\c<-cs}+++"."
  91.         ]
  92. nr_new_words_placed nr words
  93.     :==    if (nr==0)
  94.             ["No new words placed.",Wait (2*TicksPerSecond) ""]
  95.        (if (nr==1)
  96.                ["New word placed:",hd words,Wait (2*TicksPerSecond) ""]
  97.             [toString nr+++" New words placed" : words++[Wait (2*TicksPerSecond) ""]]
  98.        )
  99. has_won                :==    " has won."
  100. is_a_draw            :==    "It is a draw."
  101. is_move                :==    " is playing."
  102.  
  103. determines_new_word    :==    " determines a new word"
  104. determined_new_word    :==    " has determined a new word."
  105. found_upto_now        :==    "found word up to now:"
  106. score_upto_now        :==    "score up to now:"
  107. at_pos                :== "at:"
  108.  
  109.  
  110. //    Text used in the GUI definition.
  111.  
  112. //    The Scrabble menu:
  113. scrabblemenutitle        :==    "Scrabble"
  114. playersmenutitle        :==    "Players"
  115. newgametitle            :==    "New"
  116. quitgametitle            :==    "Quit"
  117.  
  118. //    The Strength menu:
  119. strengthmenutitle        :==    "Strength"
  120.  
  121. //    The Scrabble dialog:
  122. scrabbledialogtitle        :==    "Scrabble"
  123. scrabbledialogscore        :==    "Score"
  124. scrabbledialogword        :==    "Player word"
  125. scrabbledialogdirection    :==    "Direction"
  126. scrabbledialogplaceword    :==    "Place Word"
  127. scrabbledialoginittext lexicon
  128.     :==    [    "Number of read words: "
  129.         ,    toString (sizetree lexicon)
  130.         ,    "Depth searchtree:"
  131.         ,    toString (depthtree lexicon)
  132.         ,    Wait (2*TicksPerSecond) ""
  133.         ]
  134.  
  135. //    The Add Words dialog:
  136. addwordsheading nr
  137.     :==    if (nr==1)    ("Word does not occur.","Would you like to add it?")
  138.                     ("Words do not occur.", "Would you like to add them?")
  139. addwordstitle            :==    "Add New"
  140. addwords_yes            :==    "Yes"
  141. addwords_no                :==    "No"
  142.  
  143. //    The Save notice:
  144. save_notice_text
  145.     :==    [    "Save added words to lexicon?"
  146.         ]
  147. save_notice_yes            :==    "Yes"
  148. save_notice_no            :==    "No"
  149.